

$(document).ready(function()
{
	//initlize the send msg box
	$("a[class='send_msg']").click(function()
	{
		var receiverID=$(this).attr("name").split("_")[0];   
		var receiverName=$(this).attr("name").split("_")[1]; 
		
		$.ajax(
		{
			type: 'get',
			url: edp_domain_url + 'ajax_log_info/?tiny=1',
			timeout: 5000,
			global:false,
			beforeSend: function()
			{
				$.blockUI(
				{ 
					message: '验证用户...',
					css: { padding:'5px',color:'#CC0000'}
				});
			},
			error: function()
			{
				$.blockUI(
				{ 
					message: '验证出错...',
					css: { padding:'5px',color:'#CC0000'}
				});
				$.unblockUI();
			},
		    success: function(data)
		    { 
				if(data==false)
				{               
					popupLogin($('#PopBox'),'发送站内信');                
				}
				else
				{
					pupupSendMsg($('#PopBox'),receiverID,receiverName);
				} 
				$.blockUI(
				{ 
					message: $('#PopBox'), 
					css: 
					{ 
						padding:        0,
						margin:         0,
						top:            '30%', 
		        		left:           '35%', 
						width:          '',
						textAlign:      '', 
						color:          '', 
						border:         '',
						backgroundColor:'',       				
						cursor:         'wait'				        
					 }
				}); 		  			 	 
			}
		}); 
	});
	
	//add friend
	$("a[class='add_friend']").click(function()
	{   
		var friendID=$(this).attr("name").split("_")[0];   
		var friendName=$(this).attr("name").split("_")[1]; 
		
		$.ajax(
		{
			type: 'get',
			url: edp_domain_url + 'ajax_log_info/?tiny=1',
			timeout: 5000,
			global:false,
			beforeSend: function()
			{
				$.blockUI(
				{ 
					message: '验证用户...',
					css: { padding:'5px',color:'#CC0000'}
				});
			},
			error: function()
			{
				$.blockUI(
				{ 
					message: '验证出错...',
					css: { padding:'5px',color:'#CC0000'}
				});
				$.unblockUI();
			},
		    success: function(data)
		    { 
				if(data==false)
				{   
					popupLogin($('#PopBox'),'添加好友');                
				}
				else
				{
					popupAddFriend($('#PopBox'),friendID,friendName);
				} 
				$.blockUI(
				{ 
					message: $('#PopBox'),    
					css: 
					{ 
						padding:        0,
						margin:         0,
						top:            '30%', 
		        		left:           '35%', 
						width:          '',
						textAlign:      '', 
						color:          '', 
						border:         '',
						backgroundColor:'',       				
						cursor:         'wait'				        
					 }
				}); 			  			 	 
			}
		}); 
	});
});
/*
//js of recent add list
$(document).ready(function()
{
	//Get the total list number
	var listCount=$("div[class='list']").size();
	//Current list start index
	var listCurrent=0;
	//Display number
	var displayNum=1;
	//more list than display number
	if(listCount>displayNum)
	{
		$("div[class='list']").each(function() 
		{
			var id=$(this).attr("id").split("_")[1];
			if(id<(displayNum))
			{
				$(this).show();
			}
		})
		listCurrent=displayNum;
		$("#list_more").show();
	}
	//less list than display number
	else
	{
		$("div[class='list']").each(function() 
		{	
			$(this).show();
		})
		listCurrent=listCount;
	}
	
	//more link
	$("#list_more").click(function()
	{	
	    if(listCurrent<listCount)
	    {
	    	//Still more
	    	if((listCurrent+displayNum)<listCount)
	    	{	
	    		$("div[class='list']").each(function() 
	    		{
	    			var id=$(this).attr("id").split("_")[1];
	    			if(id<(listCurrent+displayNum))
	    			{
	    				$(this).show();
	    			}
	    			else
	    			{
	    				$(this).hide();
	    			}
		    	})
		    	listCurrent+=displayNum;
	    		$("#list_more").show();
	    	}
	    	//No more
	    	else
	    	{
	    		$("div[class='list']").each(function() 
	    	    {
	    			
	    		    $(this).show();
	    		})
	    	    listCurrent=listCount;
	    		$("#list_more").hide();
	    	}
	    	$("#list_less").show();
	    }
	}); 

	//less link
	$("#list_less").click(function()
	{
		if(listCurrent>=displayNum*2-1)
		{
			listCurrent=(parseInt((listCurrent-1)/displayNum)+1)*displayNum;
			listCurrent-=displayNum;
			$("div[class='list']").each(function() 
			{
				var id=$(this).attr("id").split("_")[1];
				if(id<listCurrent)
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			})
			
			$("#list_more").show();
			//Still less
			if(listCurrent>=displayNum*2-1)
	    		$("#list_less").show();
			//No less
			else
	    		$("#list_less").hide();
		}
	});
});
	
//js of recent collectshop
$(document).ready(function()
{	
	//Get the total collectshop number
	var collectshopCount=$("div[class='collectshop']").size();
	//Current collectshop start index
	var collectshopCurrent=0;
	//Display number
	var displayNum=2;
	//more collectshop than display number
	if(collectshopCount>displayNum)
	{
		$("div[class='collectshop']").each(function() 
		{
			var id=$(this).attr("id").split("_")[1];
			if(id<(displayNum))
			{
				$(this).show();
			}
		})
		collectshopCurrent=displayNum;
		$("#collectshop_more").show();
	}
	//less collectshop than display number
	else
	{
		$("div[class='collectshop']").each(function() 
		{	
			$(this).show();
		})
		collectshopCurrent=collectshopCount;
	}
	
	//more link
	$("#collectshop_more").click(function()
	{	
	    if(collectshopCurrent<collectshopCount)
	    {
	    	//Still more
	    	if((collectshopCurrent+displayNum)<collectshopCount)
	    	{	
	    		$("div[class='collectshop']").each(function() 
	    		{
	    			var id=$(this).attr("id").split("_")[1];
	    			if(id<(collectshopCurrent+displayNum))
	    			{
	    				$(this).show();
	    			}
	    			else
	    			{
	    				$(this).hide();
	    			}
		    	})
		    	collectshopCurrent+=displayNum;
	    		$("#collectshop_more").show();
	    	}
	    	//No more
	    	else
	    	{
	    		$("div[class='collectshop']").each(function() 
	    	    {
	    		    $(this).show();
	    		})
	    	    collectshopCurrent=collectshopCount;
	    		$("#collectshop_more").hide();
	    	}
	    	$("#collectshop_less").show();
	    }
	}); 

	//less link
	$("#collectshop_less").click(function()
	{
		if(collectshopCurrent>=displayNum*2-1)
		{
			collectshopCurrent=(parseInt((collectshopCurrent-1)/displayNum)+1)*displayNum;
			collectshopCurrent-=displayNum;
			$("div[class='collectshop']").each(function() 
			{
				var id=$(this).attr("id").split("_")[1];
				if(id<collectshopCurrent)
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			})
			
			$("#collectshop_more").show();
			//Still less
			if(collectshopCurrent>=displayNum*2-1)
	    		$("#collectshop_less").show();
			//No less
			else
	    		$("#collectshop_less").hide();
		}
	});
	
});

//js of recent addshop
$(document).ready(function()
{	
	//Get the total addshop number
	var addshopCount=$("div[class='addshop']").size();
	//Current addshop start index
	var addshopCurrent=0;
	//Display number
	var displayNum=2;
	//more addshop than display number
	if(addshopCount>displayNum)
	{
		$("div[class='addshop']").each(function() 
		{
			var id=$(this).attr("id").split("_")[1];
			if(id<(displayNum))
			{
				$(this).show();
			}
		})
		addshopCurrent=displayNum;
		$("#addshop_more").show();
	}
	//less addshop than display number
	else
	{
		$("div[class='addshop']").each(function() 
		{	
			$(this).show();
		})
		addshopCurrent=addshopCount;
	}
	
	//more link
	$("#addshop_more").click(function()
	{	
	    if(addshopCurrent<addshopCount)
	    {
	    	//Still more
	    	if((addshopCurrent+displayNum)<addshopCount)
	    	{	
	    		$("div[class='addshop']").each(function() 
	    		{
	    			var id=$(this).attr("id").split("_")[1];
	    			if(id<(addshopCurrent+displayNum))
	    			{
	    				$(this).show();
	    			}
	    			else
	    			{
	    				$(this).hide();
	    			}
		    	})
		    	addshopCurrent+=displayNum;
	    		$("#addshop_more").show();
	    	}
	    	//No more
	    	else
	    	{
	    		$("div[class='addshop']").each(function() 
	    	    {
	    		    $(this).show();
	    		})
	    	    addshopCurrent=addshopCount;
	    		$("#addshop_more").hide();
	    	}
	    	$("#addshop_less").show();
	    }
	}); 

	//less link
	$("#addshopp_less").click(function()
	{
		if(addshopCurrent>=displayNum*2-1)
		{
			addshopCurrent=(parseInt((addshopCurrent-1)/displayNum)+1)*displayNum;
			addshopCurrent-=displayNum;
			$("div[class='addshop']").each(function() 
			{
				var id=$(this).attr("id").split("_")[1];
				if(id<addshopCurrent)
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			})
			
			$("#addshop_more").show();
			//Still less
			if(addshopCurrent>=displayNum*2-1)
	    		$("#addshop_less").show();
			//No less
			else
	    		$("#addshop_less").hide();
		}
	});
});

//js of recent addproduct
$(document).ready(function()
{
	//Get the total addproduct number
	var addproductCount=$("div[class='addproduct']").size();
	//Current addproduct start index
	var addproductCurrent=0;
	//Display number
	var displayNum=2;
	//more addproduct than display number
	if(addproductCount>displayNum)
	{
		$("div[class='addproduct']").each(function() 
		{
			var id=$(this).attr("id").split("_")[1];
			if(id<(displayNum))
			{
				$(this).show();
			}
		})
		addproductCurrent=displayNum;
		$("#addproduct_more").show();
	}
	//less addproduct than display number
	else
	{
		$("div[class='addproduct']").each(function() 
		{	
			$(this).show();
		})
		addproductCurrent=addproductCount;
	}
	
	//more link
	$("#addproduct_more").click(function()
	{	
	    if(addproductCurrent<addproductCount)
	    {
	    	//Still more
	    	if((addproductCurrent+displayNum)<addproductCount)
	    	{	
	    		$("div[class='addproduct']").each(function() 
	    		{
	    			var id=$(this).attr("id").split("_")[1];
	    			if(id<(addproductCurrent+displayNum))
	    			{
	    				$(this).show();
	    			}
	    			else
	    			{
	    				$(this).hide();
	    			}
		    	})
		    	addproductCurrent+=displayNum;
	    		$("#addproduct_more").show();
	    	}
	    	//No more
	    	else
	    	{
	    		$("div[class='addproduct']").each(function() 
	    	    {
	    		    $(this).show();
	    		})
	    	    addproductCurrent=addproductCount;
	    		$("#addproduct_more").hide();
	    	}
	    	$("#addproduct_less").show();
	    }
	}); 

	//less link
	$("#addproduct_less").click(function()
	{
		if(addproductCurrent>=displayNum*2-1)
		{
			addproductCurrent=(parseInt((addproductCurrent-1)/displayNum)+1)*displayNum;
			addproductCurrent-=displayNum;
			$("div[class='addproduct']").each(function() 
			{
				var id=$(this).attr("id").split("_")[1];
				if(id<addproductCurrent)
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			})
			
			$("#addproduct_more").show();
			//Still less
			if(addproductCurrent>=displayNum*2-1)
	    		$("#addproduct_less").show();
			//No less
			else
	    		$("#addproduct_less").hide();
		}
	});
});
*/
//js used by the part of recent event
$(document).ready(function()
{	

	$("#five_event").click(function()
	{
		$(this).removeClass("show_no_current");
	    $(this).addClass("show_current");
	    $("#ten_event").removeClass("show_current");
	    $("#ten_event").addClass("show_no_current");
	    $("#twenty_event").removeClass("show_current");
	    $("#twenty_event").addClass("show_no_current");
	    	    	
	    $("#hiddenEvent10").hide();
	    $("#hiddenEvent20").hide();
	});
	
	$("#ten_event").click(function()
	{

		$(this).removeClass("show_no_current");
	    $(this).addClass("show_current");
	    $("#five_event").removeClass("show_current");
	    $("#five_event").addClass("show_no_current");
	    $("#twenty_event").removeClass("show_current");
	    $("#twenty_event").addClass("show_no_current");
		
	    $("#hiddenEvent10").show();
	    $("#hiddenEvent20").hide();
	});
	
	$("#twenty_event").click(function()
	{
		$(this).removeClass("show_no_current");
	    $(this).addClass("show_current");
	    $("#ten_event").removeClass("show_current");
	    $("#ten_event").addClass("show_no_current");
	    $("#five_event").removeClass("show_current");
	    $("#five_event").addClass("show_no_current");
		
	    $("#hiddenEvent10").show();
	    $("#hiddenEvent20").show();
	});
});

$(document).ready(function()
{
	$("a[tag='delete']").click( delete_review );
});

function delete_review()
{
	var params = "rid=" + $(this).attr('rid');
	var rid = $(this).attr('rid');
	var reviewBlock = $(this).closest('.review_item');
	
	MessageBox( '此评论和相关的图片都会被删掉，确定要删除这个评论?', '删除评论', {
		yes : function(){
					$.ajax(
					{
						type: 'post',
						url: edp_domain_url + 'ajax_del_review/?tiny=2',
						data: params,
						timeout: 5000,
						global:false,
						beforeSend: function()
						{
							$.blockUI(
							{
								message: '正在删除...',
								css: {
									padding:'35px',
									color:'#CC0000'
								}
							});
						},
						error: function()
						{
							$.blockUI(
							{
								message: '删除失败(0)...',
								css: {
									padding:'35px',
									color:'#CC0000'
								}
							});
						},
						success: function( data, textStatus )
						{
							if( data != "0" )
							{
								$.blockUI(
								{
									message: data,
									css: {
										padding:'35px',
										color:'#CC0000'
									}
								});
								setTimeout($.unblockUI, 2000);
							}
							else
							{
								setTimeout( $.unblockUI, 2000 );
								reviewBlock.css("display", "none");
							}
						}
					});
	},
	no : function(){UnblockUI();}
	});

}

